package com.qf.smsplatform.monitor.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

@Component
public class JavaMailUtil {

    @Autowired
    private JavaMailSender javaMailSender;

    public void sendMail(int count) throws MessagingException {
        // 发送邮件
        MimeMessage mimeMessage = javaMailSender.createMimeMessage();

        MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage,true);

        messageHelper.setTo("402424668@qq.com");

        messageHelper.setSubject("快来吧,项目爆炸!!!!!跑路!!!!!!");

        messageHelper.setText("text/html;charset=utf-8","<h1 style='color:red;'>快跑路吧, 这个公司没个干~~~,消息数量为: "+count+" </h1>");

        messageHelper.setFrom("zjw_2301211@126.com");

        javaMailSender.send(mimeMessage);
    }



}
